{% extends 'feedback/base.html' %}
{% block title %} 
    Список нарядов в работе
{% endblock %}



{% block content %}

<meta http-equiv="refresh" content="60">

{% include "naryad/menu.html" with address=request.resolver_match.view_name naryad_wait_count=naryad_wait_count naryad_in_work_count=naryad_in_work_count%}

<div class="container-fluid">
<table class="table table-sm">
    <thead>
        <tr>
            <th scope="col" style="width:10%" class="text-center">№ Наряда</th>
            <th scope="col" style="width:10%" class="text-center">Специальность</th>
            <th scope="col" style="width:10%" class="text-center">Специалист</th>
            {% comment %} <th scope="col" style="width:17%" class="text-center">Передать</th> {% endcomment %}
            <th scope="col" style="width:17%" class="text-center">Пациент</th>
            {% comment %} <th scope="col" style="width:8%" class="text-center">Изображения</th> {% endcomment %}
            <th scope="col" style="width:18%" class="text-center">Комментарий</th>
            <th scope="col" style="width:7%" class="text-center">Услуги</th>
            <th scope="col" style="width:7%" class="text-center">Дней на этапе</th>
        </tr>
    </thead>
</table>
{% for naryad in naryad_list %}

    {% if naryad.images.all %}
    {% comment %} <details>
        <summary> {% endcomment %}
    <table class="table table-success table-striped table-sm table-hover ">
    {% else %}
    <table class="table table-sm table-hover ">
    {% endif %}
    <tbody>
        <tr>
            <td style="width:10%" class="text-center"><a  href="{% url 'naryad_upd' naryad.id %}" class="btn btn-block"> <b>{{ naryad.nkv }}</b></a></td>
            <td style="width:10%" class="text-center">{{ naryad.sdl_etap.name_sdl }}</td>
            <td style="width:10%" class="text-center">{{ naryad.current_spec_fio }}</td>
            {% comment %} {% if naryad.sdl_etap.sdl == 1 and naryad.id_etap != 1 %}

                <td style="width:17%" class="text-center"><a href="{% url 'next_etap' naryad.id 35%}">
                    <span class="d-inline-block" tabindex="0" data-bs-toggle="popover" data-bs-trigger="hover focus" data-bs-placement="bottom" data-bs-content="Передать Технику">
                        <input class="" type="image" src="/static/img/tech.png" alt="Передать технику" width="30" height="30" class="me-2">
                        </span></a>
                </td>
            {% elif naryad.sdl_etap.sdl == 35 and naryad.id_etap != 1%}
                <td style="width:17%" class="text-center">
                    <div class="row">
                        <div class="col">
                <span class="d-inline-block" tabindex="0" data-bs-toggle="popover" data-bs-trigger="hover focus" data-bs-placement="bottom" data-bs-content="Передать врачу">
                    <a href="next_etap/{{ naryad.id }}/1"><input class="" type="image" src="/static/img/doctor.png" alt="Передать врачу" width="30" height="30" class="me-2"></a> 
                </span>
            </div>
            <div class="col">
                <span class="d-inline-block" tabindex="0" data-bs-toggle="popover" data-bs-trigger="hover focus" data-bs-placement="bottom" data-bs-content="Передать литейщику">
                <a href="{% url 'next_etap' naryad.id 36%}"><input class="" type="image" src="/static/img/ltk.png" alt="Передать литейщику" width="30" height="30" class="me-2"></a>
                </span>
            </div>
            <div class="col">
                <span class="d-inline-block" tabindex="0" data-bs-toggle="popover" data-bs-trigger="hover focus" data-bs-placement="bottom" data-bs-content="Передать полировщику">
                <a href="{% url 'next_etap' naryad.id 37%}"><input class="" type="image" src="/static/img/plk.png" alt="Передать полировщику" width="30" height="30" class="me-2"></a>
                </span>
            </div>
            <div class="col">
                <span class="d-inline-block" tabindex="0" data-bs-toggle="popover" data-bs-trigger="hover focus" data-bs-placement="bottom" data-bs-content="Передать CadCam">
                <a href="{% url 'next_etap' naryad.id 38%}"><input class="" type="image" src="/static/img/cadcam.png" alt="Передать CadCam" width="30" height="30" class="me-2"></a></td>
                </span>
            </div>
        </div>
            {% elif naryad.sdl_etap.sdl == 36 and naryad.id_etap != 1 %}
            <td style="width:17%" class="text-center"><a href="{% url 'next_etap' naryad.id 35%}">
                <span class="d-inline-block" tabindex="0" data-bs-toggle="popover" data-bs-trigger="hover focus" data-bs-placement="bottom" data-bs-content="Передать Технику">
                    <input class="" type="image" src="/static/img/tech.png" alt="Передать технику" width="30" height="30" class="me-2">
                    </span></a>
            </td>
            {% elif naryad.sdl_etap.sdl == 37 and naryad.id_etap != 1 %}
            <td style="width:17%" class="text-center"><a href="{% url 'next_etap' naryad.id 35%}">
                <span class="d-inline-block" tabindex="0" data-bs-toggle="popover" data-bs-trigger="hover focus" data-bs-placement="bottom" data-bs-content="Передать Технику">
                    <input class="" type="image" src="/static/img/tech.png" alt="Передать технику" width="30" height="30" class="me-2">
                    </span></a>
            </td>
            {% elif naryad.sdl_etap.sdl == 38 and naryad.id_etap != 1 %}
            <td style="width:17%" class="text-center"><a href="{% url 'next_etap' naryad.id 35%}">
                <span class="d-inline-block" tabindex="0" data-bs-toggle="popover" data-bs-trigger="hover focus" data-bs-placement="bottom" data-bs-content="Передать Технику">
                    <input class="" type="image" src="/static/img/tech.png" alt="Передать технику" width="30" height="30" class="me-2">
                    </span></a>
            </td>
            {% else %}
                <td style="width:17%" class="text-center">Некому передать</td>
            {% endif %} {% endcomment %}
            <td style="width:17%" class="text-center">{{ naryad.patient.fam }} {{ naryad.patient.im|slice:"1" }}. {% if naryad.patient.ot != " "%} {{ naryad.patient.ot|slice:"1" }}.{% endif %}</td>
            {% comment %} <td style="width:8%" class="text-center">
                {% if naryad.images.all %}
                {{ naryad.images.all|length }}
                {% else %}
                Нет
                {% endif %}
            </td> {% endcomment %}
            <td style="width:18%" class="text-center">
                {% if naryad.kom_etap|length > 0 %}
                {{ naryad.kom_etap }}
                {% else %}
                Нет
                {% endif %}
            </td>
            <td style="width:7%" class="text-center">
                <div
                    hx-get="{% url 'uslugi_modal' naryad.id %}"
                    hx-swap="innerHTML"
                    hx-target="#place_for_modal"
                    hx-select="#modal_uslui"
                    hx-trigger="click"
                    class="btn btn-block"
                    > <b>Услуги</b>
                </div>
            </td>
            <td style="width:7%" class="text-center">{{ naryad.get_days }}</td>
            {% comment %} <td style="width:6%" class="text-center">{{ naryad.id_etap }}</td> {% endcomment %}
        </tr>
    </tbody>
</table>

    {% comment %} {% if naryad.images.all or naryad.kom_etap %}
        </summary>
    {% endif %} {% endcomment %}
    {% comment %} {% for photo in naryad.images.all %}
        <td ><img hx-get="{% url 'image_fullscreen' photo.id %}"
            hx-target="#place_for_modal"
            hx-select="#imageview_modal"
            hx-swap="innerHTML"
            hx-trigger="click" src="{{ photo.img.url }}" style="width:100px;height:100px;" alt=""></td>
    {% endfor %} {% endcomment %}
    {% comment %} {% if naryad.images.all or naryad.kom_etap %}
        </details>
    {% endif %} {% endcomment %}

{% endfor %}
</div>
<div id="place_for_modal">
</div>
<script>
    var popoverTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="popover"]'))
var popoverList = popoverTriggerList.map(function (popoverTriggerEl) {
  return new bootstrap.Popover(popoverTriggerEl)
})
</script>

<div id="place_for_modal">
</div>
{% endblock %}